Skip to content

Fix the Memory screen loading forever in offline review - #10115

Open
maheshrijal wants to merge 2 commits into
flutter:masterfrom
maheshrijal:fix-memory-offline-review
Open

maheshrijal wants to merge 2 commits into
flutter:masterfrom
maheshrijal:fix-memory-offline-review

Conversation

@maheshrijal

@maheshrijal maheshrijal commented Dec 3, 2026 •

Copy link
Copy Markdown

Fixes #10103

When the app disconnects, DevTools saves each screen's data so you can click Review recent data (offline). The Memory screen saved its live DiffPaneController, ProfilePaneController, ChartData, and TracePaneController objects. DevTools then disposed the connected MemoryController, which also disposed those objects. The offline MemoryController reused them, threw when it used a disposed ValueNotifier, and never completed initialized.

prepareOfflineScreenData now converts the data to maps and lists with toJson. The offline MemoryController builds new controllers from them, the same way it does for an imported file. Heap snapshot graphs are kept as references, so a large snapshot is not copied.

This change has two side effects:

  1. The offline Memory screen analyzes heap snapshots again, as it does after a file import.
  2. A snapshot that is still loading when the app disconnects is not saved.

Tests

I added two tests. Both fail on master and pass with this change.

  • memory_screen_test.dart saves the data, disposes the connected controller as a disconnect does, and loads the offline Memory screen.
  • memory_controller_test.dart checks that the offline data shares no disposable objects with the connected controller, and that it keeps the same heap graph.

I also ran DevTools locally in debug mode, connected it to a Dart CLI app, took a heap snapshot, stopped the app, and clicked Review recent data (offline). On master, the Memory screen showed a spinner that never stopped, and the console logged "Error loading offline data for memory". With this change, the offline Memory screen shows the chart history, the Profile Memory table, and the heap snapshot in Diff Snapshots.

Before (master): the Memory screen keeps loading after clicking Review recent data (offline).

Before: the Memory screen keeps loading

After: the offline Memory screen shows the recorded data.

After: the offline Memory screen loads

Pre-launch Checklist

General checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read the Flutter Style Guide recently, and have followed its advice.
  • I signed the CLA.
  • I updated/added relevant documentation (doc comments with ///).

Issues checklist

Tests checklist

  • I added new tests to check the change I am making...
  • OR there is a reason for not adding tests, which I explained in the PR description.

AI-tooling checklist

  • I did not use any AI tooling in creating this PR.
  • OR I did use AI tooling, and...
    • I read the AI contributions guidelines and agree to follow them.
    • I reviewed all AI-generated code before opening this PR.
    • I understand and am able to discuss the code in this PR.
    • I have verifed the accuracy of any AI-generated text included in the PR description.
    • I commit to verifying the accuracy of any AI-generated code or text that I upload in response to review comments.

Feature-change checklist

  • This PR does not change the DevTools UI or behavior and...
    • I added the release-notes-not-required label or left a comment requesting the label be added.
  • OR this PR does change the DevTools UI or behavior and...
    • I added an entry to packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md.
    • I included before/after screenshots and/or a GIF demo of the new UI to my PR description.
    • I ran the DevTools app locally to manually verify my changes.

build.yaml badge

If you need help, consider asking for help on Discord.

When the app disconnected, MemoryController.prepareOfflineScreenData
saved its live DiffPaneController, ProfilePaneController, ChartData,
and TracePaneController objects as the offline data. DevTools then
disposed the controller, and that also disposed those objects. The
offline MemoryController reused the disposed objects. In debug builds,
a disposed ValueNotifier throws when it is used, so `initialized` never
completed and the screen kept showing a spinner.

prepareOfflineScreenData now converts the data to maps and lists with
toJson. The offline MemoryController builds new controllers from them,
the same way it does for an imported file. Heap snapshot graphs are
kept as references, so the data is not copied.

Fixes flutter#10103
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

maheshrijal added a commit to maheshrijal/devtools that referenced this pull request Dec 3, 2026
maheshrijal added a commit to maheshrijal/devtools that referenced this pull request Dec 3, 2026
@maheshrijal
maheshrijal marked this pull request as ready for review December 3, 2026 06:10
@maheshrijal
maheshrijal requested review from a team and kenzieschmoll as code owners December 3, 2026 06:10
@maheshrijal
maheshrijal requested review from srawlins and removed request for a team December 3, 2026 06:10
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory screen: "Review recent data (offline)" fails in debug builds with "used after being disposed"

1 participant